<?
header('Content-type: text/xml', true);
echo('<?xml version="1.0" encoding="utf-8"?' . '>');
include('../base.php');
User::protect();
include_class('venues');
include_class('locations');

echo("<xml>\n");

if ($_GET['stateProvince'] && $_GET['city']) {

	$limiter['country'] = $_GET['country'];
	$limiter['stateProvince'] = $_GET['stateProvince'];
	$limiter['city'] = $_GET['city'];
	$sl = new VenueList();
	$venuelist = $sl->get($limiter);
	
	foreach ($venuelist as $vn) {
		echo("\t");
		echo('<venue id="' . $vn->getID() . '">' . htmlentities($vn->getName()) . '</venue>');
		echo("\n");
	}

} else if ($_GET['stateProvince']) { 

	$limiter['country'] = $_GET['country'];
	$limiter['stateProvince'] = $_GET['stateProvince'];
	$sl = new VenueList();
	$citylist = $sl->getCityList($limiter);
	
	foreach ($citylist as $ci => $total) {
		echo("\t");
		echo('<city id="' . htmlentities($ci) . '">' . htmlentities($ci) . ' (' . $total . ')</city>');
		echo("\n");
	}
} else if ($_GET['country']) { 

	$sl = new VenueList();
	$spl = new StateList();
	$statelist = $spl->getStates();
	$splist = $sl->getStateProvinceList($_GET['country']);
	
	foreach ($splist as $sp => $total) {
		$stateProvince = ($statelist[$sp]) ? $statelist[$sp] : $sp;		
		echo("\t");
		echo('<sp id="' . htmlentities($sp) . '">' . htmlentities($stateProvince) . ' (' . $total . ')</sp>');
		echo("\n");
	}
}

echo("</xml>");

?>